package com.dawn.module.hospital.controller.app.patient;

import com.dawn.framework.apisign.core.annotation.Sign;
import com.dawn.framework.common.pojo.CommonResult;
import com.dawn.module.hospital.controller.app.patient.vo.PatientCreateReqVO;
import com.dawn.module.hospital.controller.app.patient.vo.PatientDelReqVO;
import com.dawn.module.hospital.controller.app.patient.vo.PatientQueryReqVO;
import com.dawn.module.hospital.controller.app.patient.vo.PatientUpdateClinicNoVO;
import com.dawn.module.hospital.service.PatientService;
import com.dawn.module.hospital.service.ehealth.bean.CheckUniformVerifyReq;
import com.dawn.module.hospital.service.ehealth.bean.HealthCodeReq;
import com.dawn.module.hospital.service.ehealth.bean.RegisterUniformVerifyOrderReq;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * @description:
 * @author: cnsu-cmh
 * @time: 2024/8/7 11:37
 */
@Tag(name = "用户 APP - bh")
@RestController
@RequestMapping("/bh/patient")
@Validated
public class AppPatientController {

    @Autowired
    private PatientService patientService;

    @Sign
    @PostMapping(value = "/list")
    @Operation(summary = "获取就诊档案")
    public CommonResult list(@Valid @RequestBody PatientQueryReqVO reqVO){
        return patientService.list(reqVO);
    }

    @PostMapping(value = "/create")
    @Operation(summary = "创建就诊档案")
    public CommonResult create(@Valid @RequestBody PatientCreateReqVO reqVO){
        return patientService.create(reqVO);
    }

    @Sign
    @PostMapping(value = "/delete")
    @Operation(summary = "删除就诊档案")
    public CommonResult delete(@Valid @RequestBody PatientDelReqVO reqVO) {
        return patientService.delete(reqVO);
    }

    @Sign
    @PostMapping(value = "/updateClinicNo")
    @Operation(summary = "更新门诊号")
    public CommonResult updateClinicNo(@Valid @RequestBody PatientUpdateClinicNoVO reqVO) {
        return patientService.updateClinicNo(reqVO.getWxUserId(), reqVO.getId(), reqVO.getOpenid(), reqVO.getPatientId(),reqVO.getCardNo());
    }

    @Sign
    @PostMapping(value = "/detail")
    @Operation(summary = "获取就诊档案")
    public CommonResult detail(@Valid @RequestBody PatientDelReqVO reqVO) {
        return patientService.findPatientById(reqVO);
    }

    @Sign
    @PostMapping(value = "/eHealth/cfg")
    @Operation(summary = "获取电子健康卡配置")
    public CommonResult eHealthCfg(){
        return patientService.getEHealthCfg();
    }

    @Sign
    @PostMapping(value = "/eHealth/list")
    @Operation(summary = "电子健康码列表页")
    public CommonResult eHealthList(@Valid @RequestBody PatientQueryReqVO reqVO){
        return patientService.eHealthList(reqVO);
    }

    @Sign
    @PostMapping(value = "/eHealth/detail")
    @Operation(summary = "获取电子健康卡档案")
    public CommonResult eHealthDetail(@Valid @RequestBody PatientDelReqVO reqVO) {
        return patientService.findPatientEHealthById(reqVO);
    }

    @Sign
    @PostMapping(value = "/eHealth/code")
    @Operation(summary = "获取电子健康卡信息")
    public CommonResult eHealthByCode(@RequestBody HealthCodeReq reqVO){
        CommonResult result = patientService.getEHealthByCode(reqVO);
        return result;
    }

    @Sign
    @PostMapping(value = "/eHealth/registerUniformVerifyOrder")
    @Operation(summary = "获取电子健康卡实人认证生成orderId")
    public CommonResult registerUniformVerifyOrder(@RequestBody RegisterUniformVerifyOrderReq reqVO){
        CommonResult result = patientService.registerUniformVerifyOrder(reqVO);
        return result;
    }

    @Sign
    @PostMapping(value = "/eHealth/checkUniformVerifyResult")
    @Operation(summary = "获取电子健康卡实人认证生成orderId")
    public CommonResult checkUniformVerifyResult(@RequestBody CheckUniformVerifyReq reqVO){
        CommonResult result = patientService.checkUniformVerifyResult(reqVO);
        return result;
    }

    @Sign
    @PostMapping(value = "/eHealth/takeMsCard")
    @Operation(summary = "电子健康卡进入卡包OrderID")
    public CommonResult takeMsCard(@Valid @RequestBody PatientDelReqVO reqVO) {
        return patientService.takeMsCard(reqVO);
    }
}
